package com.pingan.haofang.searchcloud.api.query.parser.dbobject;

import javax.sql.DataSource;

public class DataNode {

    private String dataSourceName;

    private DataSource dataSource;

    private String dbName;

    public DataNode() {
    }

    public DataNode(String dataSourceName, DataSource dataSource, String dbName) {
        this.dataSourceName = dataSourceName;
        this.dataSource = dataSource;
        this.dbName = dbName;
    }

    public DataSource getDataSource() {
        return dataSource;
    }

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public String getDbName() {
        return dbName;
    }

    public void setDbName(String dbName) {
        this.dbName = dbName;
    }

    public String getDataSourceName() {
        return dataSourceName;
    }

    public void setDataSourceName(String dataSourceName) {
        this.dataSourceName = dataSourceName;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((dataSourceName == null) ? 0 : dataSourceName.hashCode());
        result = prime * result + ((dbName == null) ? 0 : dbName.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        DataNode other = (DataNode) obj;
        if (dataSourceName == null) {
            if (other.dataSourceName != null) {
                return false;
            }
        } else if (!dataSourceName.equals(other.dataSourceName)) {
            return false;
        }
        if (dbName == null) {
            if (other.dbName != null) {
                return false;
            }
        } else if (!dbName.equals(other.dbName)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "DataNode [dataSourceName=" + dataSourceName + ", dbName=" + dbName + "]";
    }
}
